const Router = require('@koa/router')//导入路由包
const router = new Router();//实例化路由
router.get('/',(ctx, next) =>{
    ctx.body = `来到用户界面`
});

router.get('/getAllusers',(ctx, next) =>{
    ctx.body = {
        code:200,
        msg:'获取成功',
        data:[
            {name:'zs',password:'123456'}
        ]
    }
});

router.post('/login',(ctx, next) =>{
    const {name,password} = ctx.request.body
    if(name=='zs'&&password=='123456'){
        ctx.body={
            code:222,
            msg:'欢迎登录'
        }
    }else{
        ctx.body={
            code:111,
            msg:'登录失败'
        }
    }
});

router.get('/register',(ctx, next) =>{
    const name = ctx.query.name
    ctx.body = `欢迎注册 ${name}`
});
module.exports = router; // 导出路由，以便在其他文件中使用